<?php
/*
	分红中心
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['ischecklogin']=model('jy_weishop/member')->checklogin('','','','',true);
	$return['worker']=$this->model('model')->checkworker();
	$return['group']=pdo_get('jy_shopworker_group',array('uniacid'=>$_SESSION['uniacid'],'id'=>$return['worker']['groupid']));
	$return['group2']=pdo_get('jy_shopworker_group',array('uniacid'=>$_SESSION['uniacid'],'id'=>$return['worker']['group2id']));
	$return['group2']['shifeeset']=json_decode($return['group2']['shifeeset'],true);
	$return['group2']['feeset']=json_decode($return['group2']['feeset'],true);
	$return['worker']['feeinfo']=$return['worker']['status']==2?$return['group2']['feeset']:$return['group2']['shifeeset'];
	$basic=model('core/member')->basic($_SESSION['uid']);
	$member=array_merge($member,$basic);
	$return['member']=$member;
	$data=array();
	$data['orderfee0']=$this->sum('orderlog',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$return['worker']['id'],'status'=>0),'price');
	$data['orderfee1']=$this->sum('orderlog',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$return['worker']['id'],'status'=>1),'price');
	$data['orderfee2']=$this->sum('orderlog',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$return['worker']['id'],'status'=>2),'price');
	$data['ordernum0']=$this->count('orderlog',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$return['worker']['id'],'status'=>0));
	$data['ordernum1']=$this->count('orderlog',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$return['worker']['id'],'status'=>1));
	$data['ordernum2']=$this->count('orderlog',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$return['worker']['id'],'status'=>2));
	$data['allfee']=$this->sum('feelog',array('uniacid'=>$_SESSION['uniacid'],'status'=>4,'workerid'=>$return['worker']['id']),'fee');
	$data['allfeenum']=$this->count('feelog',array('uniacid'=>$_SESSION['uniacid'],'status'=>4,'workerid'=>$return['worker']['id']));
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$data['dayprice']=$this->sum('orderlog',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$return['worker']['id'],'status'=>1,'pay_time >'=>$daytime),'price');
	$data['daybenprice']=$this->sum('orderlog',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$return['worker']['id'],'status'=>1,'pay_time >'=>$daytime),'benprice');
	$data['daylifee']=$data['dayprice']-$data['daybenprice'];
	$data['orderdayfee1']=pdo_getsum('jy_shopworker_orderlog',array('status'=>1,'workerid'=>$return['worker']['id'],'uniacid'=>$_SESSION['uniacid'],'pay_time >'=>$daytime),'price');
	$data['orderdaynum1']=pdo_count('jy_shopworker_orderlog',array('status'=>1,'workerid'=>$return['worker']['id'],'uniacid'=>$_SESSION['uniacid'],'pay_time >'=>$daytime));
	$monthtime = mktime(0,0,0,date('m'),1,date('Y'));
	$data['monthprice']=$this->sum('orderlog',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$return['worker']['id'],'status'=>1,'pay_time >'=>$monthtime),'price');
	$data['monthbenprice']=$this->sum('orderlog',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$return['worker']['id'],'status'=>1,'pay_time >'=>$monthtime),'benprice');
	$data['monthlifee']=$data['monthprice']-$data['monthbenprice'];
	foreach($data as &$row){
		$row=price($row);
	}
	$data['ordernum2']=intval($data['ordernum2']);
	$return['data']=$data;
	//公告列表
	$pindex = max(1, intval($post['page']));
	$psize = 10;
	$total='';
	$notice_list = pdo_getslice('jy_weishop_notice',array('uniacid'=>$_SESSION['uniacid'],'status'=>1),array($pindex,20),$total,array('id','title','createtime'),'','id desc');
	if($notice_list){
		foreach($notice_list as &$notice){
			$notice['createtime']=date('Y-m-d H:i',$notice['createtime']);
		}
	}
	$return['notice_list']=$notice_list;
	set_html('title','员工中心');
	exi($return);
}
?>